from digits import digits, rdigits, isPandigital
from permutations import permutations
from primes import PrimeChecker

limit = 7654321

d = digits(limit)
checker = PrimeChecker(limit)

for p in permutations(d):
    value = rdigits(p)
    if checker.is_prime(value):
        print value
        break


